import { Injectable } from "@angular/core";
import { HttpClient, HttpHeaders } from "@angular/common/http";
import { environment } from "src/environments/environment";

export interface ApiResponse<T> {
  code: string;
  message: string;
  data: T;
}

@Injectable({
  providedIn: "root"
})
export class HttpService {
  public timeout: number = environment.timeout;
  public success: string = "ok";

  constructor(private http: HttpClient) {}
  /**
   * 设置请求头
   * @param options
   * @returns
   */
  setHttpHeader(options: HttpHeaders): any {
    let httpHeaders: HttpHeaders = new HttpHeaders();

    return {
      headers: httpHeaders,
      withCredentials: true
    };
  }
}
